<extend name="Public:main" />
<block name="title">首页</block>
<block name="custom_css">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/vpay/css/swiper.min.css">
    <style type="text/css">
        .sgin{
            position: absolute;
            top: 25%;
            z-index: 111;
            height: 85%;
        }
        .sgin div{
            position: relative;
        }
        .sgin div p{
            position: absolute;
            font-size: 0.3rem;
            top: 18%;
            left: 50%;
            width: 2rem;
            margin-left: -1rem;
            text-align: center;
            color: #e4503e;
            font-weight: 600;
        }
        .sgin div label{
            position: absolute;
            font-size: 0.24rem;
            bottom: 30%;
            left: 50%;
            width: 2rem;
            margin-left: -1rem;
            text-align: center;
            color: #ffdf4c;
        }
        .sgin a{
            background: #e4503e;
            position: absolute;
            bottom: 20%;
            z-index: 111;
            display: block;
            text-align: center;
            width: 2rem;
            left: 50%;
            margin-left: -1rem;
            color: #ffdf4c;
            height: 0.4rem;
            line-height: 0.4rem;
            border-radius: 20px;
            font-size: 0.16rem;
        }
    </style>
</block>
<block name="body">
    <body ng-app="myApp" ng-controller="userCtrl" ng-cloak>
    <div class="nav_top flex" style="background: none">
        <a  href="javascript:void(0)" style="color: #fff;line-height: 0.44rem;font-size: 0.12rem;text-indent: 0.12rem;">
            UID:{{ userInfo.id }}
        </a>
        <div class="flex1">
            首页
        </div>
        <a class="set_up" href="{:U('Member/index')}">
            <i></i>
        </a>
    </div>
    <div>
        <img src="__PUBLIC__/vpay/images/home_bg_top.png">
    </div>
    <div class="pos-r index_user">
        <div class="flex user_infor" >
            <div class="flex1">
                <a href="{:U('Member/balanceRecord')}">
                    <label>{{ userInfo.balance }}</label>
                    <p>余额</p>
                </a>
            </div>
            <div>
                <div ng-if="userInfo.profilephoto != null">
                    <a href="{:U('Member/index')}">
                        <img ng-src="{{ userInfo.profilephoto }}">
                    </a>
                </div>
                <div ng-if="userInfo.profilephoto == null">
                    <a href="{:U('Member/index')}">
                        <img src="__PUBLIC__/vpay/images/shezhi_icon_head.png">
                    </a>
                </div>
            </div>
            <div class="flex1">
                <a href="{:U('Member/integral_record')}">
                    <label>{{ userInfo.integral }}</label>
                    <p>积分</p>
                </a>
            </div>
        </div>
        <div class="user_sao" onclick="user_sao()">
            <img src="__PUBLIC__/vpay/images/home_btn_scan.png">
        </div>
        <!--<div hidden>
            <input id="qrcode" name="qrcode" type="file" accept="image/*">
        </div>-->
    </div>
    <div class="swiper-container t1">
        <div class="swiper-wrapper">
            <volist name="showImg" id="vo">
                <div class="swiper-slide">
                    <a href="{$vo.url}" target="_blank"><img src="{$vo.img}"></a>
                </div>
            </volist>
        </div>
        <div class="swiper-pagination"></div>
    </div>
    <div class="user_list clearfix">
        <ul>
            <li>
                <a href="{:U('Transfer/turn_out')}">
                    <i></i>
                    <div>
                        转出
                    </div>
                </a>
            </li>
            <li>
                <a href="{:U('Transfer/change_into')}">
                    <i></i>
                    <div>
                        转入
                    </div>
                </a>
            </li>
            <li>
                <a href="{:U('Transaction/purchase')}">
                    <i></i>
                    <div>
                        买入
                    </div>
                </a>
            </li>
            <li>
                <a href="{:U('Transaction/sellOut')}">
                    <i></i>
                    <div>
                         卖出
                    </div>
                </a>
            </li>
            <li>
                <a href="{:U('Virtualcurrency/digital_assets')}">
                    <i></i>
                    <div>
                        数字资产
                    </div>
                </a>
            </li>
             <li>
               <a href="javascript:void(0)" ng-click="Unopened()">
                   <i></i>
                   <div>
                        商城
                   </div>
               </a>
           </li>
        </ul>
    </div>
        <div class="masks" style="" ng-click="signOut()"></div>
        <div class="sgin" style="display: none" ng-click="signIn();">
            <div>
                <img src="__PUBLIC__/vpay/images/qiandao_icon_kaibao.png">
                <p>
                    {{userInfo.sign_balance}}
                </p >
                <label>
                    XTU签到红包
                </label>
            </div>
            <a href="javascript:void(0);">
                存入余额
            </a>
        </div>
    </body>
    <block name="custom_js">
        <script type="text/javascript" src="__PUBLIC__/vpay/js/swiper.min.js"></script>
        <script>
            function user_sao(){
                window.onerror=function(){
                    return true;
                }
                if(navigator.userAgent.match(/(Android)/i)){
                    window.android.call_qr_andriod();
                }
                if(navigator.userAgent.match(/(iPhone|iPod|ios)/i)){

                    call_qr();
                }
            }

            function qr_text(qr_text) {

                if (qr_text == '' || qr_text == 'null' || qr_text == null || qr_text == undefined || qr_text == 'undefined') {
                    layer.msg("扫码失败！");
                    return;
                }

                $.ajax({
                    url: "{:U('Transfer/qr_text')}",
                    type: "post",
                    dataType: "json",
                    data: {
                        qr_text: qr_text,
                    },
                    timeout: 5000,
                    success: function (result) {
                        if (0 == result.code) {
                            window.location.href = result.data.url;
                        } else {
                            layer.msg(result.msg);
                        }
                    },
                    error: function (result) {
                    }
                })
            }

            $(function(){
                var mySwiper = $('.t1').swiper({
                    prevButton: '.t1 .swiper-button-prev',
                    nextButton: '.t1 .swiper-button-next',
                    pagination: '.swiper-pagination',
                    loop:true,
                    grabCursor: true,
                    paginationClickable: true,
                    autoplay: 3000,
                });
                $(".masks").click(function () {
                    $(".sgin").hide();
                });
            })
        </script>
        <script>
            var app = getApp('myApp', []);
            //用户余额 积分
            app.controller('userCtrl', function ($scope, $http) {
                $http({
                    method: 'GET',
                    url: "/index.php/Home/Index/usermessage"
                }).then(function successCallback(response) {
                    if (response.data.code == -1) {
                        layer.msg(response.data.msg, {time: 1000})
                        setTimeout(function () {
                            window.location.href = "/index.php/Home/Login/login";
                        }, 1000)
                    } else if (response.data.code == 0) {
                        $scope.userInfo = response.data.data;
                        if(!$scope.userInfo.sign){
                            $(".masks").show();
                            $(".sgin").show();
                        }
                    }
                }, function errorCallback(response) {
                    errorHandle(response);
                });

                $scope.signIn=function () {
                    $http({
                        method: 'POST',
                        data: {
                        },
                        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                        transformRequest: function (obj) {
                            var str = [];
                            for (var p in obj) {
                                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                            }
                            return str.join("&");
                        },
                        url: "/index.php/Home/Index/sign_balance",
                    }).then(function successCallback(response) {
                        if (response.data.code == -1) {
                            $(".masks").hide();
                            $(".sgin").hide();
                            layer.msg(response.data.msg, {time: 1500})
                        } else {
                            $(".masks").hide();
                            $(".sgin").hide();
                            layer.msg(response.data.msg, {time: 1500});
                        }
                        window.location.reload();
                    }, function errorCallback(response) {
                        errorHandle(response);
                    });
                }
                $scope.signOut=function () {
                    $http({
                        method: 'POST',
                        data: {
                        },
                        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                        transformRequest: function (obj) {
                            var str = [];
                            for (var p in obj) {
                                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                            }
                            return str.join("&");
                        },
                        url: "/index.php/Home/Index/signOut",
                    }).then(function successCallback(response) {
                        if (response.data.code == -1) {
                            $(".masks").hide();
                            $(".sgin").hide();
                            layer.msg(response.data.msg, {time: 1500})
                        } else {
                            $(".masks").hide();
                            $(".sgin").hide();
                            layer.msg(response.data.msg, {time: 1500});
                        }
                        window.location.reload();
                    }, function errorCallback(response) {
                        errorHandle(response);
                    });
                }
                $scope.Unopened=function () {
                    layer.msg("商城暂未开放，即将呈现敬请期待！", {time: 1500});
                }
            });
        </script>
        <script src="/Public/admin/plugins/bootstrap-fileinput/js/plugins/sortable.min.js"></script>
        <script src="/Public/admin/plugins/bootstrap-fileinput/js/plugins/purify.min.js"></script>
        <script src="/Public/admin/plugins/bootstrap-fileinput/js/fileinput.js"></script>
        <script src="/Public/admin/plugins/bootstrap-fileinput/js/locales/zh.js"></script>
    </block>
</block>